{include file="common/head"}
<head>
  <title>分类新增</title>
  <style type="text/css">
    .form-control{width: ;display: inline-block;}
  </style>
</head>
<body style="">
    <div class="container p-3 my-3 " style="max-width: 600px;"  >
    <h2>分类新增</h2>
    <form method="post" enctype="multipart/form-data" action="/index.php/cat2/cat_add">
      <div class="mb-3 mt-3">
        <lable for="fid" class="form-label">父类:</label>
        <select id="fid" name="fid" class="form-control">
            {foreach $category as $k=>$v}
              {if $v['deepth']==1}
              <option value="{$k}" >|--{$v['name']}</option>
              {elseif $v['deepth']==2}
              <option value="{$k}" >|----{$v['name']}</option>
              {elseif $v['deepth']==3}
              <option value="{$k}" >|------{$v['name']}</option>              
              {else}
              <option value="{$k}" >{$v['name']}</option>              
              {/if}
            {/foreach} 
        </select>
      </div>
      <div class="mb-3 mt-3">
        <lable for="name" class="form-label">名称:</label>
        <input type="text" class="form-control" id="name" name="name" value="" placeholder="" />
      </div>
      <div class="mb-3 mt-3">
        <lable for="name2" class="form-label">名称2:</label>
        <input type="text" class="form-control" id="name2" name="name2" value="" placeholder="" />
      </div>      
      <div class="mb-3">
        <label for="title" class="form-label">说明:</label>
        <input type="text" class="form-control" id="title" name="title" value="" placeholder="" />
      </div>

      <div class="mb-3">
        <label for="status" class="form-label">是否启用:</label>
          <input type="radio" class="form-check-input" id="radio1" name="status" value="1" checked /> 
          <label class="form-check-label" for="radio1">启用</label>
          <input type="radio" class="form-check-input" id="radio2" name="status" value="2" />
          <label class="form-check-label" for="radio2">停用</label>
       </div>
      <div class="mb-3 text-center">
        <img id="img" src="" style="width:90px;min-width: 90px;min-height: 30px;border: 1px solid #ccc;margin:0 auto;" alt="Image" />
        <label for="price_per_km" class="form-label">图片:</label>        
        <input type="file" class="form-control" name="file" id="file" /> <br> 
       </div>

      <button  type="button" class="btn btn-primary" onclick="doSave()">保存(Save)</button>

    </form>
    </div>

<script type="text/javascript">
  $(function(){



  });

  function doSave(){
    if(!$("#name").val()) {
      layer.msg("无效的分类名称(Invalid category name)!");
      return 0;
    }    
    //询问框
    layer.confirm('是否确定新增分类?', {
      btn: ['确定','取消'] //按钮
    }, function(){
      $('form').submit();
    }, function(){
      layer.msg("取消");
      return 0;
    });
  }
</script>


</body>
</html>
